package org.example.enums;

import org.example.common.BusinessException;

/**
 * @author liyishan
 * @date 2023/4/18 16:39
 */

public enum UserStateEnum {
    VALID(1, "有效"),
    INVALID(0, "禁用"),
    PULL_BLACK(-1, "拉黑");

    private Integer code;
    private String desc;

    public static UserStateEnum parse(int code) {
        UserStateEnum[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            UserStateEnum system = var1[var3];
            if (code == system.getCode()) {
                return system;
            }
        }

        throw new BusinessException("没找到此状态");
    }

    public Integer getCode() {
        return this.code;
    }

    public String getDesc() {
        return this.desc;
    }

    private UserStateEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }
}
